package de.casino;

import java.util.Collection;

import de.casino.strategies.DoubleNumberMartingaleStrategy;

public class Tester {
   public static void main(String[] args) {
      double tries = 100000.0;
      int pos = 0;
      int neutral = 0;
      int neg = 0;
      AbstractStrategy strat = new DoubleNumberMartingaleStrategy(30, 1, 50000);
      for (long i = 0; i < tries; i++) {
         long test = test(strat);
         if (test > 30) {
            pos++;
         } else if (test < 30) {
            neg++;
         } else {
            neutral++;
         }
      }
      System.out.println("Gewinnchance: " + Math.round((pos / tries * 100))
            + "%");
      System.out.println("Neutral: " + Math.round((neutral / tries * 100))
            + "%");
      System.out.println("Verlustchance: " + Math.round((neg / tries * 100))
            + "%");
   }

   private static long test(AbstractStrategy strat) {
      Collection<Result> result = strat.run(10000);
      Result last = null;
      // System.out.println("Start: " + 30);
      for (Result r : result) {
         // System.out.println(r.getSpin() + " \t Ergebnis: " + r.getResult());
         last = r;
      }
      // System.out.println("Endergebnis: " + last.getBankroll());
      return last.getBankroll();
   }
}
